from django.db import models

# 抽象类
class AbstractBase(models.Model):
    id = models.AutoField(verbose_name='自增主键',primary_key=True,db_index=True) # 自增主键
    update_at = models.DateTimeField(auto_now=True,verbose_name='修改时间') # 更新
    create_at = models.DateTimeField(auto_now_add=True,verbose_name='创建时间') # 创建
    class Meta:
        abstract = True


# user table
class User(AbstractBase):
    name = models.CharField(max_length=128,verbose_name='用户名') # user name
    pwd = models.CharField(max_length=128,verbose_name='md5加密后的密码') # pwd after md5
    email = models.EmailField(max_length=128,verbose_name='邮箱',unique=True) # 邮箱(本质是字符类型，但提供了邮件类型检测)
    major = models.CharField(max_length=128,verbose_name='专业',null=True)
    birth = models.DateTimeField(verbose_name='生日',null=True)
    age = models.IntegerField(verbose_name='年龄',null=True)
    sex = models.CharField(verbose_name='性别',max_length=8,null=True)
    class Meta:
        db_table = 'User' # define tablename in database
        managed = True


# 用户反馈---联系我们
class Comment(AbstractBase):
    send_person = models.TextField(verbose_name='联系人',null=True)
    detail = models.TextField(verbose_name='文字描述',null=True)
    img = models.ImageField(verbose_name='图片',null=True)
    email = models.EmailField(max_length=128,verbose_name='邮箱',null=True)
    class Meta:
        db_table = 'Comment'
        managed = True


# 验证码有效性的验证
class MailCode(AbstractBase):
    email = models.EmailField(max_length=128,verbose_name='邮箱')
    code = models.CharField(max_length=8,verbose_name='验证码')
    class Meta:
        db_table = 'MailCode'
        managed = True


# 用于保存测评的记录
class AccessRecords(AbstractBase):
    uid = models.ForeignKey('User',on_delete=models.CASCADE)
    create_score = models.IntegerField(verbose_name='nlp创造力最后得分',null=True)
    adventure_score = models.IntegerField(verbose_name='冒险',null=True)
    raven_scroe = models.IntegerField(verbose_name='raven得分',null=True)
    hanoi_step = models.IntegerField(verbose_name='汉诺塔步数',null=True)
    hanoi_seconds = models.IntegerField(verbose_name='汉诺塔用时',null=True)
    match_score = models.IntegerField(verbose_name='火柴',null=True)
    logic_score = models.IntegerField(verbose_name='逻辑推理',null=True)
    room_score = models.IntegerField(verbose_name='密室',null=True)
    final_score = models.FloatField(verbose_name='最终测评得分',null=True)
    class Meta:
        db_table = 'AccessRecords'
        managed = True


# 词向量
class WordVector(AbstractBase):
    word = models.CharField(verbose_name='单词',max_length=128)
    w1 = models.FloatField()
    w2 = models.FloatField()
    w3 = models.FloatField()
    w4 = models.FloatField()
    w5 = models.FloatField()
    w6 = models.FloatField()
    w7 = models.FloatField()
    w8 = models.FloatField()
    w9 = models.FloatField()
    w10 = models.FloatField()
    w11 = models.FloatField()
    w12 = models.FloatField()
    w13 = models.FloatField()
    w14 = models.FloatField()
    w15 = models.FloatField()
    w16 = models.FloatField()
    w17 = models.FloatField()
    w18 = models.FloatField()
    w19 = models.FloatField()
    w20 = models.FloatField()
    w21 = models.FloatField()
    w22 = models.FloatField()
    w23 = models.FloatField()
    w24 = models.FloatField()
    w25 = models.FloatField()
    w26 = models.FloatField()
    w27 = models.FloatField()
    w28 = models.FloatField()
    w29 = models.FloatField()
    w30 = models.FloatField()
    w31 = models.FloatField()
    w32 = models.FloatField()
    w33 = models.FloatField()
    w34 = models.FloatField()
    w35 = models.FloatField()
    w36 = models.FloatField()
    w37 = models.FloatField()
    w38 = models.FloatField()
    w39 = models.FloatField()
    w40 = models.FloatField()
    w41 = models.FloatField()
    w42 = models.FloatField()
    w43 = models.FloatField()
    w44 = models.FloatField()
    w45 = models.FloatField()
    w46 = models.FloatField()
    w47 = models.FloatField()
    w48 = models.FloatField()
    w49 = models.FloatField()
    w50 = models.FloatField()
    class Meta:
        db_table = 'WordVector'
        managed = True
